from flask import jsonify
from . import api_bp
from models import get_all_roles

@api_bp.route('/roles')
def roles():
    roles = get_all_roles()
    # 转换为字典格式
    roles_list = []
    for role in roles:
        roles_list.append({
            'id': role[0],
            'name': role[1],
            'description': role[2],
            'status': role[3],
            'created_at': role[4]
        })
    return jsonify(roles_list)